Impulse Filter (centered) will lead to no change in image. Centered impulse filter with sigma = 3 refer to 3x3 matix having 1 at (2,2) and 0 at all other locations.

Import Libraries


In [1]:
import cv2
import numpy as np
import matplotlib.pyplot as plt
import scipy.ndimage as scp

Read Image


In [2]:
img = cv2.imread('bike.jpg', cv2.IMREAD_GRAYSCALE)

Impulse Filter (centered)


In [3]:
im_filter = np.zeros((3,3))
im_filter[1,1] = 1
filtered_image = scp.correlate(img, im_filter)

In [4]:
plt.figure(figsize=(10,8))
plt.subplot(1,2,1), plt.imshow(img, cmap='gray'), plt.title('Original')


Out[4]:
(<matplotlib.axes._subplots.AxesSubplot at 0x7f1f4db74cc0>,
 <matplotlib.image.AxesImage at 0x7f1f4b278278>,
 <matplotlib.text.Text at 0x7f1f4b250860>)

In [5]:
plt.subplot(1,2,2), plt.imshow(filtered_image, cmap='gray'), plt.title('Impulse Filtered (Centered)')


Out[5]:
(<matplotlib.axes._subplots.AxesSubplot at 0x7f1f4db74a90>,
 <matplotlib.image.AxesImage at 0x7f1f4b1fd978>,
 <matplotlib.text.Text at 0x7f1f4b1c8f60>)

In [6]:
plt.show()


See!! No change.